package me.idashu.attg.service;

import java.util.List;
import java.util.Map;

import me.idashu.attg.domain.ContributionEntity;
import me.idashu.attg.persistence.ContributionMapper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ContributionService {

	@Autowired
	private ContributionMapper contributionMapper;

	public List<ContributionEntity> findContributionsByContextId(long contextId) {
		List<ContributionEntity> contributions = contributionMapper
				.findContributionsByContextId(contextId);
		return contributions;
	}

	public List<ContributionEntity> contributionsList(Map<String, Object> map) {
		return contributionMapper.contributionsList(map);
	}

	public int contributionCount(long id) {
		return contributionMapper.contributionCount(id);
	}

	public void deleteContribution(int contributionId) {
		contributionMapper.deleteContribution(contributionId);
	}

	public ContributionEntity findContributionById(long id) {
		ContributionEntity contribution = contributionMapper
				.findContributionById(id);
		return contribution;
	}

	public void insertContribution(ContributionEntity contribution) {
		contributionMapper.insertContribution(contribution);
	}
	public int countContribution(){
		return contributionMapper.countContribution();
	}
	
	public List<ContributionEntity> contributionDataStatistics(Map<String, Object> map){
		return contributionMapper.contributionDataStatistics(map);
	}

	public void updateContributionFlag(ContributionEntity contribution) {
		contributionMapper.updateContributionFlag(contribution);
	}

	public List<ContributionEntity> findContributionsByContextIdAndFlag(
			ContributionEntity contribution) {
		List<ContributionEntity> contributions = contributionMapper
				.findContributionsByContextIdAndFlag(contribution);
		return contributions;
	}
	public List<ContributionEntity> getContributionById(int id){
		return contributionMapper.getContributionById(id);
	}
}
